from pprint import pprint

from baidubaike import BAIDUBAIKE
from hudongbaike import HUDONGBAIKE
from config import NAMES
from utils import punc_split


def find_syn_by_baidubaike(word):
    res = {}
    infos = BAIDUBAIKE.info_extract_baidu(word)
    for i, info in enumerate(infos):
        for attr in NAMES:
            if attr in info:
                res[(i, attr)] = punc_split(info[attr])
    return res


def find_syn_by_hudongbaike(word):
    res = {}
    infos = HUDONGBAIKE.info_extract_hudong(word)
    for i, info in enumerate(infos):
        for attr in NAMES:
            if attr in info:
                res[(i, attr)] = punc_split(info[attr])
    return res

if __name__ == "__main__":
    pprint(find_syn_by_baidubaike('刘德华'))
    pprint(find_syn_by_baidubaike('复旦'))